package com.wtwd.device.controller;

import com.wtwd.device.model.entity.BloodOxygenList;
import com.wtwd.device.model.entity.SetBloodOxygenWarning;
import com.wtwd.device.model.vo.FrequencyAndValueVo;
import com.wtwd.device.model.vo.ResultVO;
import com.wtwd.device.service.BloodOxygenListService;
import com.wtwd.device.service.SetBloodOxygenWarningService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "血氧模块相关")
@RestController
@RequestMapping("/blood-oxgen")
public class BloodOxygenController {

    @Autowired
    private BloodOxygenListService bloodOxygenListService;

    @Autowired
    private SetBloodOxygenWarningService bloodOxygenService;

    @ApiOperation(value = "获取血氧列表可选项值", notes = "")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Success", response = BloodOxygenList.class)
    })
    @RequestMapping(value = "/getBloodOxygenList" , method = RequestMethod.GET)
    public ResultVO getBloodOxygenList(){
        List<BloodOxygenList> bloodOxygenList = bloodOxygenListService.getBloodOxygenList();
        return ResultVO.success(bloodOxygenList);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceId", value = "设备id", required = true,dataType = "long")
    })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Success", response = FrequencyAndValueVo.class)
    })
    @ApiOperation(value = "通过设备id获取当前设备设置的血氧值")
    @GetMapping(value = "/getBloodOxygenWarningByDeviceId/{deviceId}")
    public ResultVO getBloodOxygenWarningByDeviceId(@PathVariable("deviceId") Long deviceId){
        FrequencyAndValueVo bloodOxygenWarningByDeviceId = bloodOxygenService.getBloodOxygenWarningByDeviceId(deviceId);
        return ResultVO.success(bloodOxygenWarningByDeviceId);
    }
}
